﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PresentationLayer.Reports;

namespace PresentationLayer.View.Reports
{
    public partial class Report_TrendAnalysisByrequisition : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            DS_Requisition ds = new DS_Requisition();
            PresentationLayer.Reports.DS_RequisitionTableAdapters.RequisitionTableAdapter ta = new PresentationLayer.Reports.DS_RequisitionTableAdapters.RequisitionTableAdapter();
          
            int m1 = Convert.ToInt32(DropDownList3.SelectedValue);
           

            string dept = DropDownList2.SelectedValue;
            string cat = DropDownList1.SelectedValue;
            


         
            if (m1 == 01)
            {
                ta.FillByJan(ds.Requisition,dept,cat);
                PresentationLayer.Reports.Report_TrendAnalysisByRequisition req = new PresentationLayer.Reports.Report_TrendAnalysisByRequisition();
                req.SetDataSource(ds);
                CrystalReportViewer2.ReportSource = req;
            
            }
            if (m1 == 02)
            {
                ta.FillByFeb(ds.Requisition, dept, cat);
                PresentationLayer.Reports.Report_TrendAnalysisByRequisition req = new PresentationLayer.Reports.Report_TrendAnalysisByRequisition();
                req.SetDataSource(ds);
                CrystalReportViewer2.ReportSource = req;

            }
            else 
            {
                ta.FillByALL(ds.Requisition,m1, dept, cat);
                
                PresentationLayer.Reports.Report_TrendAnalysisByRequisition req = new PresentationLayer.Reports.Report_TrendAnalysisByRequisition();
                req.SetDataSource(ds);
                CrystalReportViewer2.ReportSource = req;
            
            }
        }
        

        protected void Button1_Click(object sender, EventArgs e)
        {
           string m1 = DropDownList3.SelectedItem.Value;
            //int m2 = Convert.ToInt32(DateTime.Now.AddMonths(-1));
            //int m3 = Convert.ToInt32(DateTime.Now.AddMonths(-2));
            ////string m2 = DropDownList4.SelectedItem.Value;
            ////string m3 = DropDownList5.SelectedItem.Value;
            string dept = DropDownList2.SelectedItem.Value;
            string cat = DropDownList1.SelectedItem.Value;
            Response.Redirect("Print_TrendByRequisition.aspx?m1="+m1+"&dept="+dept+"&cat="+cat);
        }
    }
}